package com.jielihaofeng.shop.common;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

@Data
@AllArgsConstructor
public class Result<T> implements Serializable {
    private T data;
    private Meta meta = new Meta();

    public Result(Integer status, String message, Object data) {
        this.meta.setStatus(status);
        this.meta.setMsg(message);
        this.data = (T) data;
    }

    public Result(String message, Object data) {
        this.meta.setMsg(message);
        this.data = (T) data;
    }

    public Result(Object data) {
        this.data = (T) data;
    }

    public Result() {
    }

    public Result status(Integer status) {
        this.meta.setStatus(status);
        return this;
    }

    public Result msg(String msg) {
        this.meta.setMsg(msg);
        return this;
    }

    public Result data(T data) {
        this.data = data;
        return this;
    }
}
